home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / person / pascross.zip / CROSS.PAS < prev    next >
Pascal/Delphi Source File  |  1980-01-07  |  5KB  |  168 lines

  1. Program CrossCountry;  {By Kevin Hellman}
  2.  
  3. type
  4.  string7=string[7];
  5.  string10=string[10];
  6.  Data= record            {this record holds all the good data}
  7.   Name  :string7;
  8.   School:string10;
  9.   time  :string7;
  10.   num:integer;
  11.  end; {data}
  12.  
  13. Var
  14.  datalist  : array[1..100] of data;         {this holds the records}
  15.  maxentries: integer;                       {line till EOF}
  16.  SchoolList:array[1..20] of string10;       {list of schools}
  17.  maxschools: integer;                       {number of schools}
  18.  
  19. procedure GetInfo;                          {reads that good 'ol data file}
  20. var
  21.  n:text;
  22. begin
  23.  Maxentries:=0;
  24.  Assign(N,'Runner.dat');
  25.  Reset(N);
  26.  while not(eof(N)) do
  27.   begin
  28.    maxentries:=maxentries+1;
  29.    with datalist[maxentries] do
  30.     begin
  31.      read(N,Name);
  32.      read(N,School);
  33.      read(N,Time);
  34.      readln(N,Num);
  35.     end;
  36.    end;
  37. end;  {getinfo}
  38.  
  39. Procedure Sortnames;                   {Sort those names}
  40. var                                     
  41. counter  :integer;
  42.  Templow  :string;
  43.  Previous :string;
  44.  Secounter:integer;
  45. begin
  46.  Writeln;
  47.  Writeln('Official Alphabetized List of Names');  {Yes ! the infamous}
  48.  Writeln('-------- ------------ ---- -- -----');   {Super-Kev Sort}
  49.  templow:='ZZZ';
  50.  for counter:=1 to maxentries do
  51.   if datalist[counter].Name<templow then templow:=datalist[counter].Name;
  52.   Writeln(Templow);
  53.   Previous:=templow;
  54.   For Secounter:=1 to maxentries do
  55.    begin
  56.     Templow:='ZZZ';
  57.     For counter:=1 to maxentries do
  58.       if (datalist[counter].Name<templow) and (datalist[counter].Name>previous)
  59.         then templow:=datalist[counter].Name;
  60.     if Templow<>'ZZZ' then writeln(templow);
  61.     Previous:=templow;
  62.     end;
  63. end; {Sortnames}
  64.  
  65.  
  66. Procedure SortSchools;                   {gee, now what could this do ?}
  67. var
  68.  counter  :integer;                      {NO, it is not a flight simulator}
  69.  Templow  :string;
  70.  Previous :string;
  71.  Secounter:integer;
  72. begin
  73.  Writeln;
  74.  Writeln('Official Alphabetized List of Schools');
  75.  Writeln('-------- ------------ ---- -- -------');
  76.  templow:='ZZZ';
  77.  for counter:=1 to maxentries do
  78.   if datalist[counter].School<templow then templow:=datalist[counter].School;
  79.   Writeln(Templow);
  80.   Maxschools:=1;
  81.   Schoollist[Maxschools]:=templow;
  82.   Previous:=templow;
  83.   For Secounter:=1 to maxentries do
  84.    begin
  85.     Templow:='ZZZ';
  86.     For counter:=1 to maxentries do
  87.       if (datalist[counter].School<templow) and (datalist[counter].School>previous)
  88.         then templow:=datalist[counter].School;
  89.     if Templow<>'ZZZ' then
  90.       begin
  91.        Maxschools:=Maxschools+1;
  92.        Schoollist[Maxschools]:=templow;
  93.        writeln(templow);
  94.       end;
  95.     Previous:=templow;
  96.     end;                           
  97. end;   {sortschools}
  98.  
  99. Procedure ListforEachSchool;   {prepares a list for each school}
  100. var
  101.  counter:integer;
  102.  c: integer;
  103. begin
  104.   for counter:=2 to maxschools do
  105.    begin
  106.     Writeln;
  107.     Writeln('Official list of Participants for ',Schoollist[counter]);
  108.     writeln('--------------------------------------------------------');
  109.     writeln;
  110.       For c:=1 to maxentries do
  111.        if datalist[c].school=schoollist[counter] then
  112.                Writeln(Datalist[c].name);
  113.     end;
  114. end; {list for each school}
  115.  
  116. Function Timevalue(Calcit:string):integer;    {My secret ingredient}
  117. Var                                           {Handles strings of times}
  118.  p1,p2,temp:integer;                          {IT works rather well}
  119. begin
  120.   val(calcit[1],p1,temp);
  121.   val(calcit[3]+calcit[4],p2,temp);
  122.   timevalue:=p1*60+p2;
  123. end; {timevalue}
  124.  
  125. Procedure Timelist;                     {Yes, Now it list the winners}
  126. var
  127.  counter  :integer;
  128.  Templow  :integer;
  129.  Previous :integer;                     {and losers....CSII ?}
  130.  Secounter:integer;
  131.  Lowindex :integer;
  132. begin
  133.  writeln;
  134.  Writeln('Official List of Names of Sorted Time');
  135.  Writeln('-------- ---- -- ----- -- ------ ----');
  136.  writeln;
  137.  templow:=1000;
  138.  for counter:=1 to maxentries do
  139.   if TimeValue(datalist[counter].time)<templow then
  140.      begin
  141.        templow:=TimeValue(datalist[counter].time);
  142.        Lowindex:=counter;
  143.      end;
  144.   Writeln(Datalist[lowindex].name);
  145.   Previous:=templow;
  146.   For Secounter:=1 to maxentries do
  147.    begin
  148.     Templow:=1000;
  149.     For counter:=1 to maxentries do
  150.       if (timevalue(datalist[counter].Time)<templow) and (Timevalue(datalist[counter].Time)>previous)
  151.          then
  152.           begin
  153.            templow:=TimeValue(datalist[counter].time);
  154.            Lowindex:=counter;
  155.           end;
  156.     if Templow<>1000 then writeln(Datalist[Lowindex].Name);
  157.     Previous:=templow;
  158.     end;
  159. end;      {timelist}
  160.  
  161. begin  {MAINLINE}
  162.  Getinfo;
  163.  Sortnames;
  164.  SortSchools;
  165.  Listforeachschool;
  166.  Timelist;
  167. end. {Mainline}
  168.